<?php

declare(strict_types=1);

use Hyperf\Database\Seeders\Seeder;

class InitVideoMonitorMenuSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        
        $grandParent = \App\Model\Permission\Menu::create([
            'parent_id' => 0,
            'name'  => 'videoMonitoring',
            'path'  =>  '/video-monitoring',
            'meta'  =>  new \App\Model\Permission\Meta([
                'type' => 'M',
                'title' => '监控管理',
                'i18n' => 'video-monitoring.title',
                'icon' => 'ant-design:video-camera-twotone',
                'hidden' => 0,
                'componentPath' => 'plugins/',
                'componentSuffix' => '.vue',
                'breadcrumbEnable' => 1,
                'copyright' => 1,
                'cache' => 1,
                'affix' => 0,
            ]),
        ]);

        $modelNames = [
            '摄像头' => [
                'name' => 'videoCamera',
                'i18n' => 'video-monitoring.camera.title',
                'icon' => 'ep:monitor',
                'path' => '/video-monitoring/camera',
                'component' => 'gq/video-monitoring/views/gqVideoCamera/index'
            ],
            '分类' => [
                'name' => 'videoType',
                'i18n' => 'video-monitoring.type.title',
                'icon' => 'ep:video-camera',
                'path' => '/video-monitoring/type',
                'component' => 'gq/video-monitoring/views/gqVideoType/index'
            ]
        ];

        $listName = [
            '列表' => ['name' => 'index', 'i18n' => ''],
            '新增' => ['name' => 'save', 'i18n' => ''],
            '编辑' => ['name' => 'update', 'i18n' => ''],
            '删除' => ['name' => 'delete', 'i18n' => '']
        ];

        foreach ($modelNames as $k => $v) {
            $parent = \App\Model\Permission\Menu::create([
                'parent_id' => $grandParent->id,
                'name'  => $v['name'],
                'path'  =>  $v['path'],
                'component' => $v['component'],
                'meta'  =>  new \App\Model\Permission\Meta([
                    'type' => 'M',
                    'title' => $k . '管理',
                    'i18n' => $v['i18n'],
                    'icon' => $v['icon'],
                    'hidden' => 0,
                    'componentPath' => 'plugins/',
                    'componentSuffix' => '.vue',
                    'breadcrumbEnable' => 1,
                    'copyright' => 1,
                    'cache' => 1,
                    'affix' => 0,
                ]),
            ]);
            foreach ($listName as $k2 => $v2) {
                \App\Model\Permission\Menu::create([
                    'parent_id' => $parent->id,
                    'name' => $v['name'] . $v2['name'],
                    'meta'  =>  new \App\Model\Permission\Meta([
                        'i18n' => $v2['i18n'],
                        'type' => 'B',
                        'title' => $k . $k2
                    ])
                ]);
            }
        }
    }
}